Help requested understanding Java Reflection --> Android ParcelableContainer?

Reflection should be used sparingly, or not at all if it can be avoided, and especially not as a way to hack around good design principles. That being said, it can also be useful in certain situations getDeclaredFields can return all types of fields while getFields only returns fields marked public The reason your test returns the same thing is that you're using getDeclaredFields in both statements how I get the value of 'myID You can only do that by operating on an instance of a class. E.

G T t = ... Field field = t.getClass(). GetDeclaredField("myID"); field. SetAccessible(true); String value = (String) field.

Get(t).

Reflection should be used sparingly, or not at all if it can be avoided, and especially not as a way to hack around good design principles. That being said, it can also be useful in certain situations ... getDeclaredFields can return all types of fields while getFields only returns fields marked public. The reason your test returns the same thing is that you're using getDeclaredFields in both statements.

How I get the value of 'myID' You can only do that by operating on an instance of a class. E.g. , T t = ... Field field = t.getClass().

GetDeclaredField("myID"); field. SetAccessible(true); String value = (String) field. Get(t).

Thx, Youre are right with everything you said. But as I wrote it is only for testing and learning purposes. – Rafael T Feb 19 at 17:37.

I'm, playing with the Android framework and try to get my mind deeper into Java. For This I read about Javas Generics and the Reflection API, while I'm not understanding it really. Because I'm a lazy Dev ;) I tried to write an 'Parcelable-Container' in which I can put ANY Object I wish to get it Parcelable without the need to implement this for every Object again using methods of Java Reflection.

How can I get every member even if they are Objects or private Superclass members? Public int hello.test.Testclass.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions